# Computes squared losses 
squared.loss <-function(pin){ 
	ein <- A.mat[q.pos,z.pos]%*%pin - P[q.pos,t]
	#ein <- A.mat%*%pin - p
	return(as.vector(t(ein)%*%ein))
}